package com.seteam.collabcrossword;

import com.seteam.collabcrossword.exceptions.CollabCrosswordException;

import java.io.Serializable;

/**
 * This class represents the actual crossword. It contains methods to
 * set the board, dimensions, etc
 */
public class Crossword implements Serializable {
    /**
     * This is required to ensure that the client and the server receive the
     * same object when serialized and sent over a network
     * <p/>
     * Generated using the IDE's serial version generator instead of JDK's serialver
     */
    private static final long serialVersionUID = -753547402783914474L;

    protected int dimX;
    protected int dimY;
    protected Tile[][] board;

    /**
     * Constructor
     *
     * @param x the width of the board
     * @param y the height of the board
     * @throws CollabCrosswordException if the values passed are not positive
     */
    public Crossword(final int x, final int y) throws CollabCrosswordException {
        CollabCrosswordUtils.isPositive(x, Globals.CROSSWORD_ERROR + "x cannot be negative");
        CollabCrosswordUtils.isPositive(y, Globals.CROSSWORD_ERROR + "y cannot be negative");
        dimX = x;
        dimY = y;
    }

    /**
     * Getter for dimX
     *
     * @return value of dimX
     */
    public int getDimX() {
        return dimX;
    }

    /**
     * Setter for dimX
     *
     * @param dimX the value to be set
     */
    public void setDimX(final int dimX) {
        this.dimX = dimX;
    }

    /**
     * Getter for dimY
     *
     * @return the value of dimY
     */
    public int getDimY() {
        return dimY;
    }

    /**
     * Setter for dimY
     *
     * @param dimY the value to be set
     */
    public void setDimY(final int dimY) {
        this.dimY = dimY;
    }

    /**
     * Getter for board
     *
     * @return an array of tiles
     */
    public Tile[][] getBoard() {
        return board;
    }

    /**
     * Setter for board
     *
     * @param board an array of tiles that represents the board
     */
    public void setBoard(final Tile[][] board) {
        this.board = board;
    }
}
